const KoaRouter = require('@koa/router')
const { verifyAuth } = require('../middleware/login.middleware')
const { create, read, detail, update, remove, addLables } = require('../controller/moment.controller')
const { verifyPermission } = require('../middleware/permission.middleware')
const { verifyLableExists } = require('../middleware/lable.middleware')

// 1.定义路由对象
const momentRouter = new KoaRouter({ prefix: "/moment" })

// 2.具体路由规则
// 发表动态接口
momentRouter.post('/createMoment', verifyAuth, create)
// 获取动态列表
momentRouter.get('/getMomentList', read)
// 获取某条动态详情
momentRouter.get('/getMomentById/:momentId', detail)
// 修改某条动态的content
momentRouter.patch('/updateMoment/:momentId', verifyAuth, verifyPermission, update)
// 删除某条动态
momentRouter.delete('/deleteMoment/:momentId', verifyAuth, verifyPermission, remove)
// 给动态添加标签
momentRouter.post('/:momentId/addLables', verifyAuth, verifyPermission, verifyLableExists, addLables)

module.exports = momentRouter